package com.platform.schedule.dynamic.config;

import com.platform.schedule.dynamic.annotation.DynamicSchedule;
import com.platform.schedule.dynamic.builder.DynamicScheduleContextBeanBuilder;
import com.platform.schedule.dynamic.service.DynamicScheduleService;
import com.platform.schedule.dynamic.service.impl.DynamicScheduleServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * <p>
 *
 * @author: WangYang
 * @date: 2018-01-05 14:19
 * @version: 1.0
 * @since 1.8
 */
@Configuration
@ConditionalOnClass(value = {DynamicSchedule.class})
public class DynamicScheduleAutoConfiguration {

    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        return new ThreadPoolTaskScheduler();
    }

    @Bean
    public DynamicScheduleContextBeanBuilder dynamicScheduleContextBeanBuilder() {
        return new DynamicScheduleContextBeanBuilder();
    }

    @Bean
    public DynamicScheduleService dynamicScheduleService() {
        return new DynamicScheduleServiceImpl();
    }

}
